package com.atmc.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.web.authentication.rememberme.JdbcTokenRepositoryImpl;
import org.springframework.security.web.authentication.rememberme.PersistentTokenRepository;

import javax.sql.DataSource;
/*
* 登录页面 实现记住我功能
*
* */
@Configuration
public class RememberConfig {
    //注入数据源
    @Autowired
    private DataSource dataSource;
    //配置操作数据对象
    @Bean
    public PersistentTokenRepository persistentTokenRepository(){
        JdbcTokenRepositoryImpl tokenRepository=new JdbcTokenRepositoryImpl();
        tokenRepository.setDataSource(dataSource);
        //登录账号 密码校验时，自动创建表
        //设置在启动时创建表
//        tokenRepository.setCreateTableOnStartup(true);
        return tokenRepository;
    }
}
